package com.ellricky.baselib.ui.student;

import android.view.View;
import android.widget.AdapterView;

import com.andr.common.http.callback.BaseCallback;
import com.andr.common.ui.adapter.BaseRecyclerAdapter;
import com.andr.common.ui.mvp.BasePresenter;
import com.ellricky.baselib.R;
import com.ellricky.baselib.adapter.student.StuApplyAdapter;
import com.ellricky.baselib.entity.student.StudentApplyEntity;
import com.ellricky.baselib.http.callback.EListCallback;
import com.ellricky.baselib.ui.base.BaseRefreshActivity;
import com.ellricky.baselib.util.EAppUtil;

import java.util.List;

import static com.ellricky.baselib.http.Api.API_STUDENT_APPLY_LIST;

/**
 * 申请信息
 */
public class StudentApplyListActivity extends BaseRefreshActivity<Void, BasePresenter<Void>, StudentApplyEntity> {

//    private String role;


    @Override
    public void initUIView() {
//        role = LocalCacheUtil.getCardType();
        super.initUIView();
        mTvTitle.setText(R.string.base_apply_info);
    }


    @Override
    protected BaseCallback getResponseCallback() {
        return new EListCallback<StudentApplyEntity>(this) {

            @Override
            protected void onSuccess(List<StudentApplyEntity> data, String msg) {
                dataSource = data;
                rvView.onLoadFinish(dataSource, refresh);
            }

            @Override
            protected void onErrorCode(String code, String msg) {
                super.onErrorCode(code, msg);
                rvView.onRefreshFailed(refresh);
            }


            @Override
            public void onHttpError(String code, String msg) {
                super.onHttpError(code, msg);
                rvView.onRefreshFailed(refresh);
            }
        };
    }

    @Override
    protected BaseRecyclerAdapter<StudentApplyEntity> getRvAdapter() {
        return new StuApplyAdapter(this);
    }

    @Override
    protected String getUrlPath() {
//        if (CARD_PRESIDENT.equals(role) || CARD_TEACHER_MANAGER.equals(role))
        return API_STUDENT_APPLY_LIST;
//        else if (CARD_CONSULTANT.equals(role))
//            return  API_STU_APPLY_LIST;
//
//        return "";
    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
        super.onItemClick(adapterView, view, position, l);
        StudentApplyEntity entity = adapter.get(position);
        EAppUtil.jumpStuApplyDetail(this, entity);
    }
}